package nowcoder.written_examination.huawei;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

/**
 * @author fance
 * @date 2018/6/28 10:49
 */
class ErrorFile implements Comparable<ErrorFile>{
    String fileName;
    int cnt;

    @Override
    public int compareTo(ErrorFile o) {
        return o.cnt - this.cnt;
    }

    public ErrorFile(String fileName, int cnt) {
        this.fileName = fileName;
        this.cnt = cnt;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public int getCnt() {
        return cnt;
    }

    public void setCnt(int cnt) {
        this.cnt = cnt;
    }
}
public class Main {
    public static void main(String[] args) {
//        a();
    b();
    }
    public static void b() {
        Scanner scanner = new Scanner(System.in);
        ArrayList<ErrorFile> errorFileArrayList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            String line = scanner.nextLine();
            String fileName = line.trim().substring(line.trim().lastIndexOf("\\") + 1);
            boolean flag = false;
            for (int i = 0; i < errorFileArrayList.size(); i++) {
                if (errorFileArrayList.get(i).getFileName().endsWith(fileName)) {
                    ErrorFile tmp = errorFileArrayList.get(i);
                    tmp.setCnt(tmp.getCnt() + 1);
                    errorFileArrayList.set(i,tmp);
                    flag = true;
                    break;
                }
            }

            if (flag == false) {
                ErrorFile errorFile = new ErrorFile(fileName,1);
                errorFileArrayList.add(errorFile);
            }
        }


        Collections.sort(errorFileArrayList);

        int index = 0;
        while (index < 8 && index < errorFileArrayList.size()) {
            String[] fileName = errorFileArrayList.get(index).getFileName().split(" ");

            if (fileName[0].length() > 16) {
                fileName[0] = fileName[0].substring(fileName[0].length() - 16);
            }

            System.out.println(fileName[0] + " " + fileName[1] + " " + errorFileArrayList.get(index).getCnt());

            index++;
               }

    }
    public static void a() {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();

            int[] a = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                a[i] = scanner.nextInt();
            }

            for (int i = 0; i < m; i++) {
                String op = scanner.next();
                int op1 = scanner.nextInt();
                int op2 = scanner.nextInt();
                switch (op) {
                    case "Q" : {
                        System.out.println(a_query(a,op1,op2));
                    }break;
                    case "U" : {
                        a[op1] = op2;
                    }
                }
            }
        }
    }
    public static int a_query(int[] a,int lo,int hi) {
        if (lo > hi) {
            int tmp = lo;
            lo = hi;
            hi = tmp;
        }
        int max = a[lo];
        for (int i = lo; i <= hi; i++) {
            max = Math.max(max,a[i]);
        }
        return max;
    }

}
